home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1993…ch: Other People's Memory / ADC Developer CD (1993-03) (''Other People's Memory'')_iso / Dev.CD Mar 93.iso / Tools & Apps / Misc. Utilities / Installer 3.4 / Examples - Installer 3.4 / InstallFont.r < prev    next >
Encoding:
Text File  |  1992-09-21  |  12.1 KB  |  291 lines  |  [TEXT/MPS ]

  1. /*------------------------------------------------------------------------------
  2.  *
  3.  *    Apple Macintosh Developer Technical Support
  4.  *
  5.  *  Installer 3.4 sample: installing a font resource into the appropriate place
  6.  *
  7.  *    File:        InstallFont.r -    Rez Source
  8.  *
  9.  *    by:            Rich Kubota
  10.  *
  11.  *    Copyright © 1991 Apple Computer, Inc.
  12.  *    All rights reserved.
  13.  *
  14.  *------------------------------------------------------------------------------
  15.  * This sample installs the "Times" font resource, supplied with System 7.0.1, into
  16.  * the appropriate place: the Font Folder under System 7.1 or into the System file
  17.  * for System 7.0.1 and earlier.  This sample demonstrate the use of the 'inff' 
  18.  * Font Family Resource Atom.
  19.  * It allows for custom installation/removal.
  20.  *
  21.  * Note: For installation under System 7.1, the script needs to install the font into
  22.  * the Font folder by using the new Folder Manager designator 'font'.  This means that
  23.  * the script needs to determine which system is present and act accordingly.  The font
  24.  * resource can still be installed directly into the 7.1 System file.  Under 7.1, it is
  25.  * preferable to install fonts to the Font folder.  Fonts installed into the System file
  26.  * have priority use in case of name conflicts.
  27.  *
  28.  * The reverse issue of installing fonts into the Fonts folder under 7.0.1 and earlier
  29.  * IS a problem.  In such case, fonts will not be recognized.  Easy install rules
  30.  * help to keep the user from installing the font in the wrong place.  For custom
  31.  * installation, this script should be enhanced to include a pre-installation action
  32.  * atom to check the version of the System file, should the 7.1 font package be selected.
  33.  * If the system is earlier, the code resource would alert the user that the target
  34.  * volume has an incompatible system for installing fonts to the Font folder.  
  35.  * Unfortunately, Installer 3.4 installs fonts to the Font folder if the "special-font"
  36.  * designator is used for System 7.0.1.
  37.  *
  38.  * IMPORTANT NOTE:  There exists a known BUG with Installer v3.4 when installing
  39.  * font resources.  The problem occurs when a font resource already exists on a 
  40.  * System 7.0.1 or earlier system with the same ID as the one to be installed, BUT
  41.  * with a different name.  Under such situation, the Installer remaps the new FOND 
  42.  * ID as it should, however the remapping begins with ID 0.  This normally results
  43.  * in a remap to FOND ID 1 - a System reserved FOND ID.  The result is that the
  44.  * font will never be recognized.  We have not found this problem to corrupt the
  45.  * System.  This problem will be corrected in a future release of the Installer.  
  46.  * The same problem exists in Installer 3.3.  A similar problem exists with 
  47.  * Installer 3.2 except that no remapping takes place and there will exist FOND
  48.  * resources with the same resource ID.
  49.  *----------------------------------------------------------------------------*/
  50.  
  51. #include "Types.r"                    /* for the ICON resource */
  52. #include "InstallerTypes.r"
  53.  
  54. /* You can build and complete the script with the following lines:
  55. # Note: set up floppies with the appropriate names and contents before running scriptcheck
  56. # or set up folders with the same names and contents as the floppies
  57. # put these folders in the same folder as the script or at the root directory of same disk
  58.  
  59.     rez -o "Install Font Script" -t 'bbkr' -c 'bbkr' "InstallFont.r"
  60.     setfile -a i "Install Font Script"        #mark Inited
  61.     scriptcheck -p "Install Font Script"
  62. */
  63.  
  64. /*
  65.  * To create the installation disk
  66.  * 1. Name the floppy disk "Font Installer".
  67.  * 2. Copy Installer 3.4 onto the floppy.
  68.  * 3. Copy the Times font suitcase from the 7.1 Font Installation Disk to the floppy.
  69.  * 4. Rez and ScriptCheck 3.4b2 this script, and copy to the floppy.
  70.  * 5. You're all set.
  71.  */
  72.  
  73. /* put a 1 in the creation date field of source 'infs' to have ScriptCheck set date */
  74. #define kScriptCheckSetsDate    1
  75. #define kTimesFontSize            287500  /* file is 287254 bytes + buffer */
  76.                                 /* This figure is derived from the Times font supplied */
  77.                                 /* with System 7.1. */
  78.  
  79. /* Definitions for the rules */
  80. #define fontRule71            1000
  81. #define fontRulePre71        1001
  82. #define noSystem            1002
  83.  
  84. /* Defines for the file spec atoms.  These are specifications for source and destination files */
  85. #define fsSourceFont        2000
  86. #define fsTargetSystem        2001
  87. #define fsTargetFontFolder    2002
  88.  
  89. /* This is the name of the source disk */
  90. #define FontDisk "Font Installer:"
  91.  
  92. /* where we want to install our Font. */
  93. #define TargetPath71 "special-font:"    /* Indicate that we want to install the font to
  94.                                         the Font folder for System 7.1.
  95.                                     */
  96. #define TargetPathPre71 "special-macs:"    /* Indicate that we want to install the font to
  97.                                         the System file for System 7.0.1 and ealier.
  98.                                     */
  99.  
  100. /* Definition for the packages. */
  101. #define pkTheFont71            3000
  102. #define pkTheFontPre71        3001
  103.  
  104. /* Definition for the font resource atom. */
  105. #define ffTheFont71            4000
  106. #define ffTheFontPre71        4001
  107.  
  108. /* Definition for the package comment resource */
  109. #define cmtTheFont71        5000
  110. #define cmtTheFontPre71        5001
  111. #define iconTheFont            6000
  112.  
  113. /* September 1, 1992 is the current release date I put in 'icmt' rsrcs. ScriptCheck will convert */
  114. /* this value to a LongInt seconds value needed by the Installer. */
  115. #define currentReleaseDate    9011992        
  116. #define currentVersion        101     /* Version 1.01 goes in the 'icmt' rsrc */
  117.  
  118.  
  119. /************************** Easy Install Rule resources **********************************/
  120. resource 'infr' (1) {
  121.     format0  {{
  122.         pickFirst,    {fontRule71, fontRulePre71, noSystem}     /* Select the Font rule */
  123.     }};
  124. };
  125.  
  126. resource 'inrl' (fontRule71) {
  127.     format0 {{
  128.         checkFileVersion{fsTargetSystem, 7, 0x10, release, 0},
  129.         addUserDescription {"Click Install button to install\n"},    
  130.                                             /* message to appear in Easy Install screen */
  131.         addUserDescription {"• the Times Font in the Font Folder\n"}, /* 2nd line of message */
  132.         addPackages {{pkTheFont71}}            /* installing the font package */
  133.     }};
  134. };
  135.  
  136. resource 'inrl' (fontRulePre71) {
  137.     format0 {{
  138.         checkFileVersion{fsTargetSystem, 0, 0x0, release, 0},
  139.         addUserDescription {"Click Install button to install\n"},    
  140.                                             /* message to appear in Easy Install screen */
  141.         addUserDescription {"• the Times Font into the System File\n"}, /* 2nd line of message */
  142.         addPackages {{pkTheFontPre71}}        /* installing the font package */
  143.     }};
  144. };
  145.  
  146. resource 'inrl' (noSystem) {
  147.     format0 {{
  148.         reportVolError {"There is no System on volume ^0."},
  149.     }};
  150. };
  151.  
  152. /***************************** Package Resources ************************************************/
  153. resource 'inpk' (pkTheFont71)     {    /* This package could include other atoms */
  154.     format0 {
  155.         showsOnCustom,                 /* Package appears in the Custom Install display */
  156.         removable,                    /* Package can be removed */
  157.         dontForceRestart,            /* not necessary to reboot in this case */
  158.         cmtTheFont71,                 /* package's 'icmt' resource id */
  159.         kTimesFontSize,                /* Package size must be entered manually */
  160.                                     /* ScriptCheck wont do this for us.  Note, make sure you
  161.                                         use ScriptCheck v3.4b2 or greater.  
  162.                                     */
  163.         "Install Times Font for Sys 7.1", { /* package name for package that shows on custom */
  164.             'inff', ffTheFont71;
  165.         }
  166.     }
  167. };
  168.  
  169. resource 'inpk' (pkTheFontPre71) {    /* This package could include other atoms */
  170.     format0 {
  171.         showsOnCustom,                 /* Package appears in the Custom Install display */
  172.         removable,                    /* Package can be removed */
  173.         dontForceRestart,            /* not necessary to reboot in this case */
  174.         cmtTheFontPre71,             /* package's 'icmt' resource id */
  175.         kTimesFontSize,                /* Package size must be entered manually */
  176.                                     /* ScriptCheck wont do this for us.  Note, make sure you
  177.                                         use ScriptCheck v3.4b2 or greater.  
  178.                                     */
  179.         "Install Times Font for Sys 7.0.1 and earlier", { /* package name for package that shows on custom */
  180.             'inff', ffTheFontPre71;
  181.         }
  182.     }
  183. };
  184.  
  185. /***************************** Comments ************************************************/
  186. resource 'icmt' (cmtTheFont71) {
  187.     currentReleaseDate,
  188.     currentVersion,
  189.     iconTheFont,
  190.     "This package installs the Times Font into the System 7.1 Font Folder. "
  191. };
  192.  
  193. resource 'icmt' (cmtTheFontPre71) {
  194.     currentReleaseDate,
  195.     currentVersion,
  196.     iconTheFont,
  197.     "This package installs the Times Font into the System File for System 7.0.1 and earlier."
  198. };
  199.  
  200. resource 'ICON' (iconTheFont) {
  201.         $"0430 4000 0A50 A000 0B91 1002 0822 0803"
  202.         $"1224 0405 2028 0209 4010 0111 800C 00A1"
  203.         $"8003 FFC2 7E00 FF04 0100 7F04 0300 1E08"
  204.         $"04E0 000C 08E0 000A 10E0 0009 08C0 0006"
  205.         $"0487 FE04 0288 0104 0188 0084 0088 0044"
  206.         $"0088 0044 0088 00C4 0110 0188 0228 0310"
  207.         $"01C4 04E0 0002 0800 73BF FBEE 4CA2 8A2A"
  208.         $"40AA AAEA 52AA AA24 5EA2 8AEA 73BE FB8E",
  209. };
  210.  
  211.  
  212.  
  213. /********************************************* File Specs *******************************************/
  214. /* Source File Specs */
  215. resource 'infs' (fsSourceFont) {
  216.     'FFIL',                                /* File Type */
  217.     'DMOV',                                /* Creator */
  218.     kScriptCheckSetsDate,                /* ScriptCheck fills in the creation date */
  219.     noSearchForFile,                    /* Do not search the source disk for the file */
  220.     typeCrNeedNotMatch,                    /* file type and creator on source disk must match */
  221.     FontDisk"Times"                        /* Path to the file */
  222. };
  223.  
  224. resource 'infs' (fsTargetSystem) {
  225.     'ZSYS',                                /* File Type */
  226.     'MACS',                                /* Creator */
  227.     0,                                    /* creation date not needed for target file specs */
  228.     noSearchForFile,                    /* Do not search the target disk for the file */
  229.     typeCrNeedNotMatch,                    /* match system 6 or 7 */
  230.     TargetPathPre71"System"                /* destination Path */
  231. };
  232.  
  233. resource 'infs' (fsTargetFontFolder) {
  234.     'FFIL',                                /* File Type */
  235.     'DMOV',                                /* Creator */
  236.     0,                                    /* creation date not needed for target file specs */
  237.     noSearchForFile,                    /* Do not search the target disk for the file */
  238.     typeCrNeedNotMatch,                    /* match system 6 or 7 */
  239.     TargetPath71"New York"                /* destination Path */
  240. };
  241.  
  242. /*************************************** Font Family Atoms **********************************************/
  243. resource 'inff' (ffTheFont71) {
  244.     format0 {
  245.         deleteWhenRemoving,                /* Delete the resource if remove (option-custom) is clicked    */
  246.         deleteWhenInstalling,             /* delete the target before copying new one */
  247.         copy,                             /* Copy rsrc to destination */
  248.         noTgtRequired,                     /* Target file need not exist on dest to install */
  249.         updateExisting,                 /* replace any preexisting file with the same name */
  250.         copyIfNewOrUpdate,                 /* Copy whether or not target rsrc already exists */
  251.         ignoreProtection,                /* Do it even if the target rsrc is protected */
  252.         srcNeedExist,                    /* Rsrc needs to exist on source disk */
  253.         byName,                            /* use the name to find the source and target rsrc */
  254.         nameMustMatch,                    /* this field is ignored if above is byName */
  255.         fsTargetFontFolder,                /* Target file spec to install rsrc into */
  256.         fsSourceFont,                    /* Source file spec where to get rsrc */
  257.         0x20,                            /* 'FOND' is purgeable */
  258.         kTimesFontSize,                    /* font resource size entered manually */
  259.         20,                                /* Resource ID of Times 'FOND' */
  260.         entireFamily {                    /* all strikes found in FOND to be installed */
  261.         },
  262.         "Times Font",                    /* Atom description */
  263.         "Times"                            /* Font Resource name */
  264.     };
  265. };
  266.  
  267. resource 'inff' (ffTheFontPre71) {
  268.     format0 {
  269.         deleteWhenRemoving,                /* Delete the resource if remove (option-custom) is clicked    */
  270.         dontDeleteWhenInstalling,         /* dont need to delete the target before copying new one */
  271.         copy,                             /* Copy rsrc to destination */
  272.         tgtRequired,                     /* System file need already exist on dest to install */
  273.         updateExisting,                 /* replace any preexisting DA with the same name */
  274.         copyIfNewOrUpdate,                 /* Copy whether or not target rsrc already exists */
  275.         ignoreProtection,                /* Do it even if the target rsrc is protected */
  276.         srcNeedExist,                    /* Rsrc needs to exist on source disk */
  277.         byName,                            /* use the name to find the source and target rsrc */
  278.         nameMustMatch,                    /* this field is ignored if above is byName */
  279.         fsTargetSystem,                    /* Target file spec to install rsrc into */
  280.         fsSourceFont,                    /* Source file spec where to get rsrc */
  281.         0x20,                            /* 'FOND' is purgeable */
  282.         kTimesFontSize,                    /* font resource size entered manually */
  283.         20,                                /* Resource ID of Times 'FOND' */
  284.         entireFamily {                    /* all strikes found in FOND to be installed */
  285.         },
  286.         "Times Font",                    /* Atom description */
  287.         "Times"                            /* Font Resource name */
  288.     };
  289. };
  290.  
  291.